/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package fanta.framework.persistence;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author alessandro
 */
@Entity
@Table(name = "lega")
@NamedQueries({
    @NamedQuery(name = "Lega.findAll", query = "SELECT l FROM Lega l"),
    @NamedQuery(name = "Lega.findByNome", query = "SELECT l FROM Lega l WHERE l.nome = :nome"),
    @NamedQuery(name = "Lega.findByMaxteam", query = "SELECT l FROM Lega l WHERE l.maxteam = :maxteam"),
    @NamedQuery(name = "Lega.findByDatacreazione", query = "SELECT l FROM Lega l WHERE l.datacreazione = :datacreazione"),
    @NamedQuery(name = "Lega.findByDatachiusura", query = "SELECT l FROM Lega l WHERE l.datachiusura = :datachiusura")})
public class Lega implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "nome")
    private String nome;
    @Basic(optional = false)
    @Column(name = "maxteam")
    private int maxteam;
    @Basic(optional = false)
    @Column(name = "datacreazione")
    @Temporal(TemporalType.DATE)
    private Date datacreazione;
    @Basic(optional = false)
    @Column(name = "datachiusura")
    @Temporal(TemporalType.DATE)
    private Date datachiusura;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "lega")
    private Collection<Giornatelega> giornatelegaCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "lega1")
    private Collection<Team> teamCollection;
    @JoinColumn(name = "owner", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private Utente owner;

    public Lega() {
    }

    public Lega(String nome) {
        this.nome = nome;
    }

    public Lega(String nome, int maxteam, Date datacreazione, Date datachiusura) {
        this.nome = nome;
        this.maxteam = maxteam;
        this.datacreazione = datacreazione;
        this.datachiusura = datachiusura;
    }

    public String getNome() {
        return nome;
    }

    public void setNome(String nome) {
        this.nome = nome;
    }

    public int getMaxteam() {
        return maxteam;
    }

    public void setMaxteam(int maxteam) {
        this.maxteam = maxteam;
    }

    public Date getDatacreazione() {
        return datacreazione;
    }

    public void setDatacreazione(Date datacreazione) {
        this.datacreazione = datacreazione;
    }

    public Date getDatachiusura() {
        return datachiusura;
    }

    public void setDatachiusura(Date datachiusura) {
        this.datachiusura = datachiusura;
    }

    public Collection<Giornatelega> getGiornatelegaCollection() {
        return giornatelegaCollection;
    }

    public void setGiornatelegaCollection(Collection<Giornatelega> giornatelegaCollection) {
        this.giornatelegaCollection = giornatelegaCollection;
    }

    public Collection<Team> getTeamCollection() {
        return teamCollection;
    }

    public void setTeamCollection(Collection<Team> teamCollection) {
        this.teamCollection = teamCollection;
    }

    public Utente getOwner() {
        return owner;
    }

    public void setOwner(Utente owner) {
        this.owner = owner;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (nome != null ? nome.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Lega)) {
            return false;
        }
        Lega other = (Lega) object;
        if ((this.nome == null && other.nome != null) || (this.nome != null && !this.nome.equals(other.nome))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "fanta.framework.persistence.Lega[nome=" + nome + "]";
    }

}
